<%@include file="template/configuration.jsp" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>${course.name}</title>
        ${stylesheet}
        ${jquery}
    </head>
    <body>
        <div class="container">
            <%@include file="template/header.jsp" %>
            <div class="content">
                <c:if test="${sessionScope.userrole == 'Teacher' || sessionScope.userrole == 'Administrator'}">
                    <div class="edit">
                        <a href="${url}CourseLessonEdit?courseid=${course.id}"><img src="${url}images/edit.png" border="0" /></a>
                    </div>
                </c:if>
                <h1>${course.name} lessons</h1>

                <c:if test="${isFree}"> <center><h4>The following lessons are free.</h4></center></c:if>
                    <div class="full-block">
                    <c:choose>
                        <c:when test="${fn:length(lessonList)>0}">
                            <table class="overview">
                                <tr>
                                    <th>Name</th>
                                    <th>Description</th>
                                    <th>Course</th>
                                    <th>Added on</th>
                                    <th></th>
                                </tr>
                                <c:set var="i" value="0"/>
                                <c:forEach items="${lessonList}" var="lessons">
                                    <c:set var="i" value="${i + 1}"/>
                                    <tr class="pointer <c:choose><c:when test="${i % 2 == 0}">even</c:when><c:otherwise>odd</c:otherwise></c:choose>">
                                        <td>
                                            <c:choose><c:when test="${isFree}"><a href="LectureController?id=${lessons.id}&isFree=true" class="hidden"></a></c:when>
                                                <c:otherwise><a href="LectureController?courseid=${course.id}&id=${lessons.id}" class="hidden"></a></c:otherwise>
                                            </c:choose>
                                                ${lessons.name}
                                        </td>
                                        <td>${lessons.description}</td>
                                        <td>${lessons.course.name}</td>
                                        <td>${lessons.date}</td>
                                    </tr>
                                </c:forEach>
                            </table>
                        </c:when>
                        <c:otherwise>
                            No lesson added yet.
                        </c:otherwise>
                    </c:choose>
                </div>
            </div>
            <%@include file="template/footer.jsp" %>
        </div>
    </body>
</html>
